package com.hengxinguotong.hxgtwygsp.ui.maintenance.unpaid;

import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.hengxinguotong.hxgtwygsp.R;
import com.hengxinguotong.hxgtwygsp.model.UnpaidHouse;
import com.hengxinguotong.hxgtwygsp.ui.base.BaseTabFragment;
import com.hengxinguotong.hxgtwygsp.widget.RingView;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

import butterknife.BindView;

/**
 * TODO 未缴公示
 *
 * @author hjz
 * @version V1.0.0
 * @since 2019/3/28 15:02
 */
public class UnpaidFragment extends BaseTabFragment implements UnpaidContract.IView
{
    @Inject
    UnpaidContract.IPresenter mPresenter;
    @BindView(R.id.mRingView)
    RingView mRingView;
    @BindView(R.id.unpaid_recycler)
    RecyclerView unpaidRecycler;

    private List<UnpaidHouse> unpaidHouseList = new ArrayList<>();
    private UnpaidHouseAdapter unpaidHouseAdapter;

    @Inject
    public UnpaidFragment()
    {
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState)
    {
        super.onActivityCreated(savedInstanceState);
        mPresenter.bindView(this);
    }

    @Override
    public void onDestroy()
    {
        super.onDestroy();
        mPresenter.dropView();
    }

    @Override
    public int getLayoutResId()
    {
        return R.layout.fragment_unpaid;
    }

    @Override
    public void init()
    {
        mockView();
        unpaidHouseAdapter = new UnpaidHouseAdapter(R.layout.item_unpaid_house,unpaidHouseList);
        GridLayoutManager glm = new GridLayoutManager(getContext(), 5,LinearLayoutManager.VERTICAL,false);
        unpaidRecycler.setLayoutManager(glm);
        unpaidRecycler.setAdapter(unpaidHouseAdapter);
    }

    private void mockView() {
        Resources resources = getResources();
        int[] colors = {resources.getColor(R.color.c121B71), resources.getColor(R.color.c7250FC)};
        mRingView.setColors(colors);
        float[] values = {1, 2};
        mRingView.setValues(values);

        for (int i = 0; i < 30; i++)
        {
            unpaidHouseList.add(new UnpaidHouse("一期2栋1单元1001",1));
        }
    }

}
